
class QuestionsController < ApplicationController

  def index
    @questions = Question.all
  end

  def new
    @question = Question.new
  end

  def edit
    @question = Question.find(params[:id])
  end

  def show
    @question = Question.find(params[:id])
  end
  
  def create
    @question = Question.new(params[:question])
      if @question.save
        redirect_to @question
      else
        render 'edit'
      end
  end
  
  def update
    @question = Question.find(params[:id])
    
    if @question.update_attributes(params[:question])
      redirect_to @question
    else
      render 'edit'
    end
  end
end
